#!/Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7
# -*- coding: utf-8 -*- 例如，可添加# -*- coding: utf-8 -*-

from openpyxl import load_workbook

table_name = "/Users/not_every/IdeaProjects/gitee/awesome-webapp/www/ayst/viptofail/indent_buy"
wb2 = load_workbook('%s.xlsx' % (table_name))
ws=wb2.get_sheet_names()
for row in wb2:
    for cell in row:
        # 更新订单表支付失败（我的购买中不再显示已兑换的内容）
        update1sql = 'UPDATE %s SET is_pay = 2 WHERE id = (SELECT indent_id FROM redeem_code_use WHERE redeem_code_id = (SELECT id FROM redeem_code WHERE card_number = "%s"));' % (table_name, cell[0].value)
        print(update1sql)

        # 更新兑换码使用表使用状态为已过期（APP首页不再跳转到兑换后的内容）
        update2sql = 'UPDATE redeem_code_use SET `status` = 1 WHERE redeem_code_id = (SELECT id FROM redeem_code WHERE card_number = "%s");' % (cell[0].value)
        print(update2sql)

        # 更新兑换码表状态为已过期（过期未使用不再让兑换）
        update3sql = 'UPDATE redeem_code SET `status` = 3 WHERE card_number = "%s";' % (cell[0].value)
        print(update3sql)

print("over...")
